package backTrack.review4_30;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class Class77 {

    List<List<Integer>> result=  new ArrayList<>();
    //      List<Integer> path=new ArrayList<Integer>();
    LinkedList<Integer> path=   new LinkedList<Integer>();

    public List<List<Integer>> combine(int n, int k) {
        backtracking(n,k,1);
        return result;
    }

    public  void  backtracking(int n,int k,int start){
        if (path.size()==k){
            result.add(new ArrayList<>(path));
            return;
        }

        for (int i = start; i <=n ; i++) {
            path.add(i);
            backtracking(n,k,i+1);
            path.removeLast();
        }

    }

    public static void main(String[] args) {
        Class77 class77 = new Class77();
        List<List<Integer>> combine = class77.combine(4, 2);
        System.out.println(combine.toString());
    }


}
